package com.pinyoumei.app.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.fragment.BaseLazyLoadFragment;
import com.pinyoumei.app.fragment.HistoryPTFragment;
import com.pinyoumei.app.fragment.ToDayPTFragment;
import com.pinyoumei.app.view.SlidingTabLayout;

import java.util.ArrayList;

/**
 * Created by Administrator on 2021-08-25.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-08-25        Administrator             新增Person类
 * 2021-08-25        Administrator             增加sex属性
 * 团购订单
 */
public class PTOrderSelectActivity extends BaseActivity implements View.OnClickListener {

    private SlidingTabLayout tl_1;
    private final static String[] TITLE_1 = {"今日开团","历史开团"};
    private ArrayList<BaseLazyLoadFragment> mFragments_1 = new ArrayList<>();
    private ViewPager vp_1;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pt_order_select);

        InitWidget();

        InitData();

    }



    private void InitWidget() {
        ImageView iv_close = findViewById(R.id.iv_close);
        iv_close.setOnClickListener(this);

        tl_1 = findViewById(R.id.tl_1);
        vp_1 = findViewById(R.id.vp_1);

        mFragments_1.add(ToDayPTFragment.getInstance("今日开团"));

        mFragments_1.add(HistoryPTFragment.getInstance("历史开团"));

        MyPagerAdapter mAdapter = new MyPagerAdapter(getSupportFragmentManager());
        vp_1.setAdapter(mAdapter);
        tl_1.setViewPager(vp_1);



    }

    private void InitData() {

    }



    private class MyPagerAdapter extends FragmentPagerAdapter {
        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return mFragments_1.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return TITLE_1[position];
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments_1.get(position);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        	case R.id.iv_close:
        		finish();
        		break;

        	default:
        		break;
        }
    }
}
